﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using MachineQA.Model;
using MachineQA.DataAccess;
using MachineQA.Tests.Mocks;
using System.Windows;

namespace MachineQATests
{
    [TestFixture]
    public class LocationRepositoryTests
    {
        List<Machine> EmptyMachineList = new List<Machine>();
        List<Location> EmptyLocationList = new List<Location>();
        Location DummyLocation;
        Location SecondDummyLocation;
        MockLocationRepository repo;

        [SetUp]
        public void Setup()
        {
            DummyLocation = new Location();
            DummyLocation.Id = 5;
            DummyLocation.Name = "somewhere";
            SecondDummyLocation = new Location();
            SecondDummyLocation.Id = 10;
            SecondDummyLocation.Name = "somewhereelse";
        }

        [Test]
        public void AddLocationToEmptyRepoTest()
        {
            repo = new MockLocationRepository(EmptyLocationList);
            Assert.AreEqual(0, repo.GetLocations().Count(), "Location isn't empty after creation with empty list");
            repo.AddLocation(DummyLocation);
            Assert.AreEqual(1, repo.GetLocations().Count(), "Location repo doesn't contain one element after first insert");
            Assert.AreEqual(repo.GetLocations().First(), DummyLocation, "Added location doesn't match with what is in the repo");
        }

        [Test]
        public void AddDuplicateLocationToRepoTest()
        {
            repo = new MockLocationRepository(EmptyLocationList);
            repo.AddLocation(DummyLocation);
            repo.AddLocation(DummyLocation);
            Assert.AreEqual(1, repo.GetLocations().Count());
            Assert.AreEqual(true, repo.ContainsLocation(DummyLocation));
        }

        [Test]
        public void RemoveLocationFromEmptyRepoTest()
        {
            repo = new MockLocationRepository(EmptyLocationList);
            repo.RemoveLocation(DummyLocation);
            Assert.AreEqual(0, repo.GetLocations().Count(), "Repo contains something when created with empty list.");
            repo.AddLocation(DummyLocation);
            repo.RemoveLocation(DummyLocation);
            Assert.AreEqual(false, repo.ContainsLocation(DummyLocation), "Repo still contains item after remove called on it.");
        }

        [Test]
        public void LocationRepositoryContainsOnlyShowsThingsInRepo()
        {
            repo = new MockLocationRepository(EmptyLocationList);
            repo.AddLocation(DummyLocation);
            Assert.AreEqual(true, repo.ContainsLocation(DummyLocation));
            Assert.AreEqual(false, repo.ContainsLocation(SecondDummyLocation));
        }
    }

    [TestFixture]
    public class MachineRepositoryTests
    {
        [Test]
        public void Test()
        {
            Assert.AreEqual(true, true);
        }
    }
}
